import http from './interface'
import users from './users' //用户请求
import order from './order' //订单请求
/**
 * 将业务所有接口统一起来便于维护
 * 如果项目很大可以将 url 独立成文件，接口分成不同的模块
 * 
 */
// 商品分类列表
export const searchgoods = (data) => {
    return http.request({
        url: '/api/searchgoods',
        method: 'GET', 
        data,
		// handle:true
    })
}

// 单独导出(测试接口) import {test} from '@/common/vmeitime-http/'
export const test = (data) => {
	/* http.config.baseUrl = "http://localhost:8080/api/"
	//设置请求前拦截器
	http.interceptor.request = (config) => {
		config.header = {
			"token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
		}
	} */
	//设置请求结束后拦截器
	http.interceptor.response = (response) => {
		console.log('个性化response....')
		//判断返回状态 执行相应操作
		return response;
	}
    return http.request({
		baseUrl: '',
        url: 'ajax/echo/text?name=uni-app',
		dataType: 'text',
        data,
    })
}

// 首页数据
export const home_classify = (data) => {
    return http.request({
        url: '/api/homecasual',
        method: 'GET', 
        data,
		// handle:true
    })
}
// 首页数据
export const recommend = (data) => {
    return http.request({
        url: '/api/recommend',
        method: 'POST', 
        data,
		// handle:true
    })
}
// 商品详情
export const sendgoods = (data) => {
    return http.request({
        url: '/api/sendgoods',
        method: 'GET', 
        data
    })
}
// 加入购物车
export const addGoodsToCart = (data) => {
    return http.request({
        url: '/api/add_shop_cart',
        method: 'POST', 
        data
    })
}
// 获取购物车数据
export const getCartsGoods = (data) => {
    return http.request({
        url: '/api/getCartsGoods',
        method: 'GET', 
        data
    })
}
// 修改购物车数据
export const updateGoodsToCart = (data) => {
    return http.request({
        url: '/api/update_shop_cart',
        method: 'POST', 
        data
    })
}
// 删除购物车数据
export const deleteGoodsToCart = (data) => {
    return http.request({
        url: '/api/deleteCartsGoods',
        method: 'POST', 
        data
    })
}
// 获取城市联动
export const getCityAddress = (data) => {
    return http.request({
        url: 'order/api/getCity',
        method: 'GET', 
        data
    })
}
// 默认全部导出  import api from '@/common/vmeitime-http/'
export default {
	users,
	order,
	test,
    home_classify,
	searchgoods,
	recommend,
	sendgoods,
	addGoodsToCart,
	getCartsGoods,
	updateGoodsToCart,
	deleteGoodsToCart,
	getCityAddress
}